package com.mes.md.service.impl;

import com.mes.md.mapper.WorkshopMapper;
import com.mes.md.service.WorkshopService;
import com.mes.pojo.md.MdWorkshop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author hitsune
 * @Company kafu chino
 * @Description
 * @Time 2024/10/24 16:48
 */

@Service
public class WorkshopServiceImpl implements WorkshopService {
    @Autowired
    private WorkshopMapper workshopMapper;
    @Override
    public List<MdWorkshop> queryWorkshop(MdWorkshop workshop) {
        return workshopMapper.queryWorkshop(workshop);
    }

    @Override
    public Integer deleteWorkshop(String workshopId) {
        return workshopMapper.deleteWorkshop(workshopId);
    }

    @Override
    public MdWorkshop queryWorkshopById(String workshopId) {
        return workshopMapper.queryWorkshopById(workshopId);
    }

    @Override
    public Integer updateWorkshop(MdWorkshop workshop) {
        return workshopMapper.updateWorkshop(workshop);
    }

    @Override
    public Integer insertWorkshop(MdWorkshop workshop) {
        String[] workshopId = workshopMapper.selectMaxWorkshopId().split("_");
        workshop.setWorkshopId("WS_"+String.format("%03d", Integer.parseInt(workshopId[1])+1));
        return workshopMapper.insertWorkshop(workshop);
    }
}
